{% extends 'finance_base.html' %}

{% block stylesheet %}
{{ block.super }}
{% endblock%}

{% block javascript %}
{{ block.super }}
<script type="text/javascript" src="{% url finance_static "js/jquery.tablesorter.min.js" %}"></script>
<script type="text/javascript">
$(document).ready(function(){
    $("#invoice_table").tablesorter();
    $("table.list tr:even").addClass("even");
});
</script>
{% endblock%}

{% load humanize %}
{% block content %}
<h3>{{ year }} / {{ month }} Transaction </h3>
<div id="navi">
    <ul>
        <li><a href="{% url transaction_create %}">transaction create</a></li>
        <li><a href="{% url transaction_month_csv year month %}">transaction download</a></li>
    </ul>
</div>

<h3>Transaction Summary</h3>
<table id="" class="tablesorter list">
<thead>
    <tr>
        <th>총입금액</th>
        <th>총출금액</th>
        <th>잔액</th>
        <th>호주총출금액</th>
        <th>한국총출금액</th>
    </tr>
</thead>
<tbody>
    <tr>
        <td>{{ m.deposit|intcomma }}</td>
        <td>{{ m.expense|intcomma }}</td>
        <td>{{ m.balance|intcomma }}</td>
        <td>{{ m.a_expense|intcomma }}</td>
        <td>{{ m.k_expense|intcomma }}</td>
    </tr>
</tbody>
</table>

<h3>Transaction List</h3>

{% load iuc_filters %}
<table id="" class="tablesorter list">
<thead>
    <tr>
        <th><a href="">날짜</a></th>
        <th>항목</th>
        <th>출금액</th>
        <th>입금액</th>
        <th>잔액</th>
        <th>통장</th>
        <th>구분</th>
    </tr>
</thead>
<tbody>
{% for transaction in paginator.entities %}
    <tr>
        <td><a href="{% url transaction_detail transaction.id %}">{{ transaction.date }}</a></td>
        <td>{{ transaction.category }}</td>
        <td>
            {% ifequal transaction.type "Expense" %}
                {{ transaction.amount|intcomma }}
            {% else %}
            -
            {% endifequal %}
        </td>
        <td>
            {% ifequal transaction.type "Deposit" %}
                {{ transaction.amount|intcomma }}
            {% else %}
            -
            {% endifequal %}
        </td>
        <td>{{ transaction.balance|intcomma }}</td>
        <td>{{ transaction.account|default_if_none:"-" }}</td>
        <td>{{ transaction.location|location }}</td>
    </tr>
{% endfor %}
</tbody>
</table>

{% include "paginator.html" %}

{% endblock %}
